#include <bits/stdc++.h>
#define N 1000006
#define INF 100000000
#define ls(u) tr[u].ls
#define rs(u) tr[u].rs
#define mxl(u) tr[u].mxl
#define mnr(u) tr[u].mnr
#define val(u) tr[u].val
using namespace std;
typedef long long ll;

const int n=1000000;
int Q;
multiset <int> sl[N], sr[N];
set <int> mxL, mnR;

struct Seg { int ls, rs, mxl, mnr, val; } tr[N*2];
int rt, tot;

void pushup (int u)
{
    mxl(u)=max(mxl(ls(u)), mxl(rs(u)));
    mnr(u)=min(mnr(ls(u)), mnr(rs(u)));
    val(u)=min(mnr(rs(u))-mxl(ls(u)), min(val(ls(u)), val(rs(u))));
}
void buildST (int &u, int l, int r)
{
    if (!u) { u=++tot; }
    if (l==r) { mxl(u)=-INF; mnr(u)=INF; val(u)=INF; return; }
    int md=(l+r)>>1;
    buildST(ls(u), l, md);
    buildST(rs(u), md+1, r);
    pushup(u);
}
void upd (int u, int l, int r, int id)
{
    if (l==r) {
        if (sl[id].size()==0) { mxl(u)=-INF; }
        else { mxl(u)=*sl[id].rbegin(); }
        if (sr[id].size()==0) { mnr(u)=INF; }
        else { mnr(u)=*sr[id].begin(); }
        return;
    }
    int md=(l+r)>>1;
    if (id<=md) { upd(ls(u), l, md, id); }
    else { upd(rs(u), md+1, r, id); }
    pushup(u);
}

int main ()
{
    freopen("stone.in", "r", stdin);
    freopen("stone.out", "w", stdout);

    buildST(rt, 1, n);

    scanf("%d", &Q);
    for (int t=1; t<=Q; t++) {
        char c[10]; int l, r;
        scanf("%s", c);
        scanf("%d %d", &l, &r); r--;
        if (c[0]=='A') {
            sl[r].insert(l);
            sr[l].insert(r);
            mxL.insert(l); mnR.insert(r);
            upd(rt, 1, n, l); upd(rt, 1, n, r);
        }
        else {
            sl[r].erase(sl[r].find(l));
            sr[l].erase(sr[l].find(r));
            upd(rt, 1, n, l); upd(rt, 1, n, r);
            if (sr[l].size()==0) { mxL.erase(l); }
            if (sl[r].size()==0) { mnR.erase(r); }
        }

        int ans=val(rt)+1;
        if (ans>1000000) {
            int R=*sr[*mxL.rbegin()].begin();
            int L=*sl[*mnR.begin()].rbegin();
            printf("%d\n", R-L+1);
        }
        else {
            printf("%d\n", ans);
        }
    }

    return 0;
}